import register from "@/util/register";

const app = {
    state: {
        taskList: [],
        backList: [],
        appList: register,
        focusApp: {},
    },

    getters: {
        backList: state => state.backList,
        focusApp: state => state.focusApp,
        taskList: state => state.taskList,
        appList: state => state.appList
    },

    mutations: {
        // 焦点app（前台展示）
        setFocus(state, val){
            // 如果app的状态是0
            // if (val.status === 1){
            //     state.focusApp = val
            // }
            state.focusApp = val
        },

        addTaskList(state, val){
            var taskList = state.taskList;
            let flag = taskList.find(value => value.id === val.id)
            if (!flag) taskList.push(val)
        },

        removeTaskList(state, val){
            var taskList = state.taskList;
            let index = taskList.findIndex(value => value.id === val.id)
            taskList.splice(index,1)
        }
    },

    actions: {
    }
}

export default app